//
//  ApiGetRequest.m
//  ZZBarometer
//
//  Created by ZeroDY on 2018/8/1.
//  Copyright © 2018年 周德艺. All rights reserved.
//

#import "ApiGetRequest.h"

@implementation ApiGetRequest


// 请求成功预处理
- (void)requestCompletePreprocessor {
    
}

// 请求成功过滤
- (void)requestCompleteFilter {
    
}

// 失败预处理
- (void)requestFailedPreprocessor {
    
}

//失败过滤
- (void)requestFailedFilter {
    
}


- (NSString *)requestUrl{
    if (self.apiUrl) {
        return self.apiUrl;
    }else{
        return @"/api/";
    }
}


//请求方法
- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodGET;
}

// 响应解码方式
- (YTKResponseSerializerType)responseSerializerType {
    return YTKResponseSerializerTypeJSON;
}

- (id)requestArgument{
    if (self.params) {
        return self.params;
    }
    return nil;
}

- (BOOL)statusCodeValidator {
    return YES;
}

//将字典转换成字符串 key=value&key=value&key=value
- (NSString *)URLString:(NSDictionary *)dic
{
    NSMutableArray *array = [NSMutableArray array];
    for (NSString *key in dic) {
        NSString *value = [dic objectForKey:key];
        [array addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
    }
    
    return [array componentsJoinedByString:@"&"];
}

@end
